/**
  ************************************* Copyright ******************************
  * FileName   : iap.c
  * Version    : v1.0
  * Author     : yychao
  * Date       : 2023-03-03
  * Description:
  * Function List:
  	1. ....
  	   <version>:
  <modify staff>:
  		  <data>:
   <description>:
  	2. ...
  ******************************************************************************
 */
#include "iap.h"

iapfun jump2app;


void iap_load_app(void)
{
    uint32_t appxaddr = FLASH_APP_BASE_ADDR;
    jump2app = (iapfun)*(vu32*)(appxaddr+4);
    __set_MSP(*(vu32*)appxaddr); // initialize the stack pointer

    SysTick->CTRL = 0X00; //disable SysTick
    SysTick->LOAD = 0;
    SysTick->VAL = 0;
    __set_PSP(*(__IO uint32_t*) appxaddr);
    __set_CONTROL(0);
    __disable_irq();
    RCC_DeInit();

    jump2app(); // Jump to APP.
}

